package com.hzdesk.media.koreabatchmatvector.logic.view;

import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.custom.myProgressBar;
import com.hzdesk.media.koreabatchmatvector.logic.contract.IWiFiSettingContract;
import com.hzdesk.media.koreabatchmatvector.logic.persenter.WiFiSettingPersenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.weyye.hipermission.HiPermission;
import me.weyye.hipermission.PermissionCallback;
import me.weyye.hipermission.PermissionItem;

/**
 * Created by Administrator on 2018/7/27.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class WiFiSettingActivity extends BaseActivity implements IWiFiSettingContract.IWiFiSettingView {

    @BindView(R.id.activity_wifi_setting_iv_back)
    ImageView activityWifiSettingIvBack;
    @BindView(R.id.activity_wifi_setting_iv_close)
    ImageView activityWifiSettingIvClose;
    @BindView(R.id.activity_wifi_setting_recyclerview)
    RecyclerView activityWifiSettingRecyclerview;
    @BindView(R.id.activity_mouse_list_ll_bg)
    LinearLayout activityMouseListLlBg;
    @BindView(R.id.activity_wifi_setting_my_preogress)
    myProgressBar activityWifiSettingMyPreogress;
    private String TAG = WiFiSettingActivity.class.getSimpleName();
    private WiFiSettingPersenter mWiFiSettingPersenter = new WiFiSettingPersenter(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wifi_setting);
        ButterKnife.bind(this);
        activityWifiSettingMyPreogress.refresh();
        mWiFiSettingPersenter.initRecyclerView(activityWifiSettingRecyclerview, this);
        mWiFiSettingPersenter.registeredWifiDate(this);
        mWiFiSettingPersenter.registeredWifiConnect(this);
        mWiFiSettingPersenter.initWifi(this);
    }

    @OnClick({R.id.activity_wifi_setting_iv_back, R.id.activity_wifi_setting_iv_close})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_wifi_setting_iv_back:
                mWiFiSettingPersenter.onclikcedWiFiSettingbacak();
                break;
            case R.id.activity_wifi_setting_iv_close:
                mWiFiSettingPersenter.onClickedWiFiOpenOrCloes(this);
                break;
        }
    }

    @Override
    public void WiFiSettingbacak() {
        finish();
    }

    @Override
    public void showOpen() {
        activityWifiSettingIvClose.setBackgroundResource(R.drawable.video_player_canvas_open);
    }

    @Override
    public void showcloase() {
        activityWifiSettingIvClose.setBackgroundResource(R.drawable.video_player_canvas_close);
    }


    @Override
    public void showProgress() {
        activityWifiSettingMyPreogress.setVisibility(View.VISIBLE);
    }

    @Override
    public void hidenProgress() {
        activityWifiSettingMyPreogress.setVisibility(View.GONE);
    }

    @Override
    protected void onStart() {
        super.onStart();
        final SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        int selector = mSharedPreferences.getInt("item_skin", 0); //todo 名称
        activityMouseListLlBg.setBackgroundResource(updateBg[selector]);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        mWiFiSettingPersenter.unRegisteredWifiDate(this);
        mWiFiSettingPersenter.unRegisteredWifiConnect(this);
    }

}
